package com.tangmu.rabbits.adapter.home;

import android.content.Context;
import android.graphics.Typeface;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.tangmu.rabbits.R;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2018/4/28.
 */

public class TodayHotsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {

    private Context mContext;
    private LayoutInflater inflater;
    private List<Integer> datas = new ArrayList<>();
    protected Typeface mTfLight;

    public TodayHotsAdapter(Context mContext, List<Integer> datas) {
        this.mContext = mContext;
        this.datas = datas;
        inflater = LayoutInflater.from(mContext);
    }

    @NonNull
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new HotsViewHolder(inflater.inflate(R.layout.rv_item_today_goods_hots, parent, false));
    }

    @Override
    public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
        HotsViewHolder viewHolder = (HotsViewHolder) holder;
        mTfLight = Typeface.createFromAsset(mContext.getAssets(), "xingkai.ttf");
        int rank = position + 1;
        viewHolder.tvHotsRanking.setText("" + rank);
        viewHolder.tvHotsRanking.setTypeface(mTfLight);//设置字体
        viewHolder.tvSellNumm.setTypeface(mTfLight);
    }

    @Override
    public int getItemCount() {
        return datas.size();
    }

    class HotsViewHolder extends RecyclerView.ViewHolder {

        @BindView(R.id.tv_hots_ranking)
        TextView tvHotsRanking; //排名
        @BindView(R.id.tv_sell_numm)
        TextView tvSellNumm; //热卖数量
        @BindView(R.id.ll_item_rank_top)
        LinearLayout llItemRankTop;
        @BindView(R.id.iv_hots_image)
        ImageView ivHotsImage; //商品图片
        @BindView(R.id.tv_hots_name)
        TextView tvHotsName; //商品名称
        @BindView(R.id.tv_discount_title)
        TextView tvDiscountTitle; //
        @BindView(R.id.tv_hots_discount_price)
        TextView tvHotsDiscountPrice; //折扣价

        public HotsViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }

}
